package org.cxy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.cxy.model.IdRange;
import org.cxy.entity.TargetTable;

@Mapper
public interface TargetTableMapper extends BaseMapper<TargetTable> {
    
    /**
     * 查询主键ID范围
     */
    @Select("SELECT MIN(id) as minId, MAX(id) as maxId, COUNT(id) as totalRecords " +
            "FROM your_target_table WHERE is_deleted = 0 AND status = 'PENDING'")
    IdRange selectIdRange();
    
    /**
     * 查询分段数据
     */
    @Select("SELECT * FROM your_target_table " +
            "WHERE id BETWEEN #{startId} AND #{endId} AND is_deleted = 0 AND status = 'PENDING' " +
            "ORDER BY id")
    java.util.List<TargetTable> selectBySegment(@Param("startId") Long startId, 
                                               @Param("endId") Long endId);
}